home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000172_icon-group-sender _Mon Aug 31 09:30:28 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id JAA01114
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 31 Aug 1998 09:30:28 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA21473; Mon, 31 Aug 1998 09:30:03 -0700
  7. Date: Mon, 31 Aug 1998 09:05:25 -0700
  8. From: kwalker@sfo.harbinger.com (Ken Walker)
  9. Message-Id: <199808311605.JAA20565@varda.premenos.com>
  10. To: icon-group@optima.CS.Arizona.EDU
  11. Subject: Re: A hood fan is guard to mind.
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=us-ascii
  14. Content-Transfer-Encoding: 7bit
  15. Content-Md5: +9a2kKmLIC6wRuNurqTDbA==
  16. Content-Transfer-Encoding: 7bit
  17. Content-Transfer-Encoding: 7bit
  18. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  19. Content-Transfer-Encoding: 7bit
  20. Status: RO
  21. Content-Length: 1542
  22.  
  23. How about a version of polyspoonerisms that uses recursive generators.
  24. It allows the sentence to be arbitrarily long by changing only data
  25. and not the number of nested "every" expressions.
  26.  
  27. procedure main()
  28.    local fillers, firstChar, remainingChars
  29.  
  30.    #
  31.    # The sentence is broken into three categories:
  32.    #   parts not participating in the substitution
  33.    #   the initial characters of the words involved in substitution
  34.    #   the tail of the words involved in substitution
  35.    #
  36.    fillers :=    ["A ",    " ",  " is ", " to ",    "."]
  37.    firstChar :=     ["g",    "m",   "h",     "f"]
  38.    remainingChars := ["ood",  "an",  "ard",    "ind"]
  39.  
  40.    polyspoonerism(fillers, firstChar, remainingChars, "")
  41. end
  42.  
  43. procedure polyspoonerism(
  44.   fillers,        # words before each participating word
  45.   firstChar,      # first characters to use in substitutions
  46.   remainingChars, # words (w/out 1st char) that are participating
  47.   sentence)       # sentence so far
  48.  
  49.   local indx
  50.  
  51.   if *remainingChars = 0 then {
  52.      write(sentence, fillers[1] | "")
  53.      return
  54.   }
  55.  
  56.   #
  57.   # Use each of the remaining first characters
  58.   #
  59.   every indx := 1 to *firstChar  do {
  60.      #
  61.      # Add the next set of parts to the sentence then call
  62.      # the function recursively.
  63.      #
  64.      polyspoonerism(fillers[2:0],
  65.         firstChar[1:indx] ||| firstChar[indx+1:0],
  66.         remainingChars[2:0],
  67.         sentence || fillers[1] || firstChar[indx] || remainingChars[1])
  68.   }
  69. end
  70.  
  71.  
  72. Ken Walker, kenneth.walker@sfo.harbinger.com
  73. Harbinger Coporation, Concord, Ca. 94520
  74.  
  75.